<cfparam name="returnView" type="string" default="" />

<cfscript>
	userGateway = new assets.calgrants.com.gateway.UserGateway();
	users = userGateway.query(regionIDs = IIf(IsUserInRole("Regional Admin"), request.authUser.regionID, ""), Organization_ID = IIf(IsUserInRole("Organizer") OR IsUserInRole("Site Contact"), request.authUser.organizationID, ""));
</cfscript>

<cfif users.RecordCount gt 0>

	<table class="table table-striped table-bordered">
		<thead>
			<tr>
				<th>Name</th>
				<th>Role</th>
				<th>E-mail</th>
				<th>Workshops</th>
				<th>Orders</th>
				<th>Status</th>
				<th class="action"></th>
			</tr>
		</thead>
		<tbody>
			<cfoutput query="users">
				<tr>
					<td>#First_Name# #Last_Name#</td>
					<td>#Role#</td>
					<td><a href="mailto:#Email#">#Email#</a></td>
					<td>#Workshop_Count#</td>
					<td>#Order_Count#</td>
					<td>
						<cfif Deleted>
							<font color="red">Deleted</font>
						<cfelseif Archived>
							<font color="silver">Archived</font>
						<cfelseif NOT Approved>
							<font color="orange">Not Approved</font>
						<cfelseif Approved>
							Approved
						</cfif>
					</td>
					<td><a href="?view=editUser&returnView=#view#&User_ID=#User_ID#" class="btn btn-success btn-block">Edit</a></td>
				</tr>
			</cfoutput>
		</tbody>
	</table>
	
<cfelse>
	<div class="alert alert-info notFound">No users</div>
</cfif>


<!--- <cfset stubbed = true>

<cfif stubbed>
Stubbed
<cfelse>

<cfparam name="Organization_ID" type="integer" default="0" />

<cfscript>
	userGateway = new assets.calgrants.com.gateway.UserGateway();
	users = userGateway.query(Organization_ID = Organization_ID);
</cfscript>

<cfif users.RecordCount gt 0>
	<table class="table table-striped table-bordered">
		<thead>
			<tr>
				<th>ID</th>
				<th>Name</th>
				<th>Role</th>
				<th>E-mail</th>
				<th>Phone</th>
				<th>Status</th>
			</tr>
		</thead>
		<tbody>
			<cfoutput query="users">
				<tr>
					<cfif IsUserInRole("Super User")>
						<td><a href="#script_name#?view=editUser&userID=#User_ID#">#User_ID#</a></td>
					<cfelseif IsUserInRole("Regional Admin")>
						<cfif Role neq "Super User">
							<td><a href="#script_name#?view=editUser&userID=#User_ID#">#User_ID#</a></td>
						<cfelse>
							<td>#User_ID#</td>
						</cfif>
					<cfelseif IsUserInRole("Organizer")>
						<cfif Role neq "Super User" and Role neq "Regional Admin">
							<td><a href="#script_name#?view=editUser&userID=#User_ID#">#User_ID#</a></td>
						<cfelse>
							<td>#User_ID#</td>
						</cfif>
					<cfelse>
						<cfif User_ID eq request.authUser.userID>
							<td><a href="#script_name#?view=editUser&userID=#User_ID#">#User_ID#</a></td>
						<cfelse>
							<td>#User_ID#</td>
						</cfif>
					</cfif>
					<td>#First_Name# #Last_Name#</td>
					<td>#Role#</td>
					<td>#Email#</td>
					<td>#Phone#</td>
					<td>
						<cfif Approved eq 1>
							Approved
						<cfelse>
							<font color="red">Not Approved</font>
						</cfif>
					</td>
				</tr>
			</cfoutput>
		</tbody>
	</table>
<cfelse>
	<div class="alert alert-info notFound">No users</div>
</cfif>

</cfif> --->